package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IEngineeringInstallOrderDetailForTeamView;
import com.cloudsigns.factorymanager2.engineering.IView.IEngineeringInstallOrderDetailView;
import com.cloudsigns.factorymanager2.engineering.bean.EngineeringInstallationOrderBean;
import com.cloudsigns.factorymanager2.engineering.model.EngineeringInstallOrderDetailForTeamModel;
import com.cloudsigns.factorymanager2.engineering.model.EngineeringInstallOrderDetailModel;
import com.cloudsigns.factorymanager2.engineering.model.IEngineeringInstallOrderDetailForTeamModel;
import com.cloudsigns.factorymanager2.engineering.model.IEngineeringInstallOrderDetailModel;

/**
 * Created by tony on 2018/4/10.
 */

public class EngineeringInstallOrderDetailForTeamPresenter {
    private IEngineeringInstallOrderDetailForTeamView view;
    private IEngineeringInstallOrderDetailForTeamModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public EngineeringInstallOrderDetailForTeamPresenter(IEngineeringInstallOrderDetailForTeamView view) {
        this.view = view;
        this.model = new EngineeringInstallOrderDetailForTeamModel();
    }

    public void getEngineeringInstallOrderDetailForTeam() {

        model.getEngineeringInstallOrderDetailForTeam(view.getOrderId(), new EngineeringInstallOrderDetailForTeamModel.OnEngineeringInstallOrderDetaiForTeamlListener() {
            @Override
            public void successed(final EngineeringInstallationOrderBean engineeringInstallationOrderBean) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getEngineeringInstallOrderDetailSuccessed(engineeringInstallationOrderBean);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getEngineeringInstallOrderDetailFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });


    }

    interface OnEngineeringInstallOrderDetaiForTeamlListener {
        void successed(EngineeringInstallationOrderBean engineeringInstallationOrderBean);

        void failed(String desc);
    }
}
